﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CompanyBussiness;

namespace Website.admin
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        System.Web.UI.Control ct;
        HtmlGenericControl genControl;
        AccountManagement accountMana = new AccountManagement();
        VwPermissionUser vw = new VwPermissionUser();
        Account acc = new Account();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session[CONST.SESSION_ACCOUNTUSER]== null || Session[CONST.SESSION_ACCOUNTUSER].ToString()=="")
                {
                    accountMana.LogOut();
                    Response.Redirect("Login.aspx");
                }
            }

           


            if (Request.QueryString[CONST.ACTION] != null)
            {
                PlaceHolderAdminMain.Controls.Clear();
                genControl = new HtmlGenericControl("div");
                if (Request[CONST.ACTION] == "ChangePass")
                    ct = Page.LoadControl("Control/cChangePass.ascx");
                else if (Request[CONST.ACTION] == "CategoryNews")
                    ct = Page.LoadControl("Control/cCategoryNews.ascx");
                else if (Request[CONST.ACTION] == "CreateCategory")
                    ct = Page.LoadControl("Control/cCategoryDetail.ascx");
                else if (Request[CONST.ACTION] == "AddNewCategory")
                    ct = Page.LoadControl("Control/cCategoryCreate.ascx");///tao dang muc
                else if (Request[CONST.ACTION] == "ListNews")
                    ct = Page.LoadControl("Control/cListNews.ascx");
                else if (Request[CONST.ACTION] == "CreateNews")
                    ct = Page.LoadControl("Control/cNewsDetail.ascx");
                else if (Request[CONST.ACTION] == "TypeProduct")
                    ct = Page.LoadControl("Control/cTypeProduct.ascx");
                else if (Request[CONST.ACTION] == "ParentTypeProductDetail")
                    ct = Page.LoadControl("Control/cTypeProductDetail.ascx");
                else if (Request[CONST.ACTION] == "AddNewTypeProduct")
                    ct = Page.LoadControl("Control/cTypeProductCreate.ascx");
                else if (Request[CONST.ACTION] == "CreateProduct")
                    ct = Page.LoadControl("Control/cProductDetail.ascx");
                else if (Request[CONST.ACTION] == "AccountMana")
                    ct = Page.LoadControl("Control/cAccountManagement.ascx");
                else if (Request[CONST.ACTION] == "CreateAccount")
                    ct = Page.LoadControl("Control/cUserAddNew.ascx");
                else if (Request[CONST.ACTION] == "AccountPermission")
                    ct = Page.LoadControl("Control/cPermissionAccount.ascx");
                else if (Request[CONST.ACTION] == "UpdateAccount")
                    ct = Page.LoadControl("Control/cUserEdit.ascx");
                else if (Request[CONST.ACTION] == "CreateMetadata")
                    ct = Page.LoadControl("Control/cMetadata.ascx");
                else if (Request[CONST.ACTION] == "ListProperty")
                    ct = Page.LoadControl("Control/cListProperty.ascx");
                else if (Request[CONST.ACTION] == "CreatProperty")
                    ct = Page.LoadControl("Control/cCreatProperty.ascx");
                //else
                //    ct = Page.LoadControl("Control/.ascx");

                genControl.Controls.Add(ct);
                PlaceHolderAdminMain.Controls.Add(genControl);
            }
            else
            {
                PlaceHolderAdminMain.Controls.Clear();
            }

        }
    }
}
